//
// Created by Kobe LI on 16/4/21.
// Copyright (c) 2016 bao. All rights reserved.
//

#import "ServiceUser.h"
#import "ServiceUtils.h"
#import "AccountManager.h"
#import "M_Fuli.h"

#import "UIAlertView+Blocks.h"
#import "PersonalEditInformationViewController.h"
#import "UIApplication+VisibleViewController.h"
#import "ModalViewController.h"
@implementation ServiceUser

/**
 *  获取验证码
 *
 *  @param phoneNum_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doGetPhoneCode:(NSString *)phoneNum_
                                 success:(void (^)(id responseObject,NSString *message))success_
                                 failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_get_phone_code;
  
    NSDictionary *dic = @{@"phone_num": phoneNum_};

    
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            
            if (code == 200) {
                success_(message,@"成功");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}


/**
 *  注册
 *
 *  @param phoneNum_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doRegister:(NSString *)phoneNum_
                            password:(NSString *)password_
                                code:(NSString *)code_
                             success:(void (^)(id responseObject,NSString *message))success_
                             failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_register;
    
    NSDictionary *dic = @{@"phone_num": phoneNum_,
                          @"password": password_,
                          @"code": code_};
    
    
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            
            if (code == 200) {
                NSDictionary *data =[responseObject objectForKey:@"data"];
                AccountManager *accountManager = [AccountManager sharedAccountManager];
                accountManager.f_isLogined = YES;
                accountManager.f_uid = [data objectForKey:@"userid"];
                accountManager.f_userName = [data objectForKey:@"username"];
                accountManager.f_nickname = [data objectForKey:@"nickname"];
                accountManager.f_point = [data objectForKey:@"point"];
                accountManager.f_user_img = [data objectForKey:@"user_img"];
                accountManager.f_phone_num = [data objectForKey:@"phone_num"];
                accountManager.f_member_level = [data objectForKey:@"member_level"];
                accountManager.f_usercode = [data objectForKey:@"usercode"];
                accountManager.f_isQQBinding = [[data objectForKey:@"bind_qq"] boolValue];
                accountManager.f_isSinaBinding = [[data objectForKey:@"bind_weibo"] boolValue];
                accountManager.f_isWechatBinding = [[data objectForKey:@"bind_weixin"] boolValue];
                accountManager.f_eliminate = [data objectForKey:@"eliminate"];
                accountManager.f_encrypt = [data objectForKey:@"encrypt"];
                success_(message,@"成功");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}



/**
 *  登录
 *
 *  @param phoneNum_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doLogin:(NSString *)phoneNum_
                         password:(NSString *)password_
                          success:(void (^)(id responseObject,NSString *message))success_
                          failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_login;
    
    NSDictionary *dic = @{@"phone_num": phoneNum_,
                          @"password": password_};
    
    
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];

            if (code == 200) {
                
                NSDictionary *data =[responseObject objectForKey:@"data"];
                AccountManager *accountManager = [AccountManager sharedAccountManager];
                accountManager.f_isLogined = YES;
                accountManager.f_uid = [data objectForKey:@"userid"];
                accountManager.f_userName = [data objectForKey:@"username"];
                accountManager.f_nickname = [data objectForKey:@"nickname"];
                accountManager.f_point = [data objectForKey:@"point"];
                accountManager.f_user_img = [data objectForKey:@"user_img"];
                accountManager.f_phone_num = [data objectForKey:@"phone_num"];
                accountManager.f_member_level = [data objectForKey:@"member_level"];
                accountManager.f_usercode = [data objectForKey:@"usercode"];
                accountManager.f_isQQBinding = [[data objectForKey:@"bind_qq"] boolValue];
                accountManager.f_isSinaBinding = [[data objectForKey:@"bind_weibo"] boolValue];
                accountManager.f_isWechatBinding = [[data objectForKey:@"bind_weixin"] boolValue];
                accountManager.f_eliminate = [data objectForKey:@"eliminate"];
                accountManager.f_encrypt = [data objectForKey:@"encrypt"];
                

                success_(nil,@"成功");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}



/**
 *  第三方注册登录
 *
 *  @param openid_
 *  @param typeid_ 第三方类型（1：qq; 2:weibo; 3:weixin）
 *  @param imgpath_ 头像路径
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doThirdPartLogin:(NSString *)openid_
                                  nickname:(NSString *)nickname_
                                    typeid:(NSString *)typeid_
                                   imgpath:(NSString *)imgpath_
                                   success:(void (^)(id responseObject,NSString *message))success_
                                   failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_thirdpart_login;
    
    NSDictionary *dic = @{@"openid": openid_,
                          @"nickname": nickname_,
                          @"typeid": typeid_,
                          @"imgpath": imgpath_};
    
    
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            
            if (code == 200) {
                NSDictionary *data =[responseObject objectForKey:@"data"];
                AccountManager *accountManager = [AccountManager sharedAccountManager];
                accountManager.f_isLogined = YES;
                accountManager.f_uid = [data objectForKey:@"userid"];
                accountManager.f_userName = [data objectForKey:@"username"];
                accountManager.f_nickname = [data objectForKey:@"nickname"];
                accountManager.f_point = [data objectForKey:@"point"];
                accountManager.f_user_img = [data objectForKey:@"user_img"];
                accountManager.f_phone_num = [data objectForKey:@"phone_num"];
                accountManager.f_member_level = [data objectForKey:@"member_level"];
                accountManager.f_usercode = [data objectForKey:@"usercode"];
                accountManager.f_isQQBinding = [[data objectForKey:@"bind_qq"] boolValue];
                accountManager.f_isSinaBinding = [[data objectForKey:@"bind_weibo"] boolValue];
                accountManager.f_isWechatBinding = [[data objectForKey:@"bind_weixin"] boolValue];
                accountManager.f_eliminate = [data objectForKey:@"eliminate"];
                accountManager.f_encrypt = [data objectForKey:@"encrypt"];
                success_(message,@"成功");
                
                if (![AccountManager sharedAccountManager].f_phone_num || [[AccountManager sharedAccountManager].f_phone_num isEqualToString:@""]) {
                    [UIAlertView showWithTitle:@"提示" message:@"请绑定手机号" cancelButtonTitle:@"取消" otherButtonTitles:@[@"确认"] tapBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
                        if (buttonIndex == 1)
                        {
                            //2016-6-22 hold left menu
                            [AppDelegate sharedAppDelegate].myOpen = @"1";
//                            //绑定手机号
//                            [[AppDelegate sharedAppDelegate].sideMenuViewController hideMenuViewController];
//                            
//                            UIStoryboard *personalCenterStoryBoard = [UIStoryboard storyboardWithName:@"PersonalCenter" bundle:[NSBundle mainBundle]];
//                            PersonalEditInformationViewController *controller = [personalCenterStoryBoard instantiateViewControllerWithIdentifier:@"PersonalEditInformationViewController"];
//                            controller.hidesBottomBarWhenPushed = YES;
//                            controller.title=@"个人信息";
//                            
//                            [[[UIApplication sharedApplication] visibleViewController].navigationController pushViewController:controller animated:YES];
                            
                            //显示模态窗体
                            ModalViewController *mvc =  [[ModalViewController alloc] init];
                            mvc.delegate = self;
                            [mvc initStyle];
                            
                            [[[UIApplication sharedApplication] visibleViewController].navigationController presentViewController:mvc animated:YES completion:^(void){
                                mvc.view.superview.backgroundColor = [UIColor clearColor];
                                
                            }];
                        }
                    }];
                    
                    return;
                }
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}



/**
 *  查询用户信息
 *
 *  @param userid_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doGetUserInfo:(NSString *)userid_
                                success:(void (^)(id responseObject,NSString *message))success_
                                failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_get_user;
    
    NSDictionary *dic = @{@"userid": userid_};
    
    
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            
            if (code == 200) {
                NSDictionary *data =[responseObject objectForKey:@"data"];
                AccountManager *accountManager = [AccountManager sharedAccountManager];
                accountManager.f_isLogined = YES;
                accountManager.f_uid = [data objectForKey:@"userid"];
                accountManager.f_userName = [data objectForKey:@"username"];
                accountManager.f_nickname = [data objectForKey:@"nickname"];
                accountManager.f_point = [data objectForKey:@"point"];
                accountManager.f_user_img = [data objectForKey:@"user_img"];
                accountManager.f_phone_num = [data objectForKey:@"phone_num"];
                accountManager.f_member_level = [data objectForKey:@"member_level"];
                accountManager.f_usercode = [data objectForKey:@"usercode"];
                accountManager.f_isQQBinding = [[data objectForKey:@"bind_qq"] boolValue];
                accountManager.f_isSinaBinding = [[data objectForKey:@"bind_weibo"] boolValue];
                accountManager.f_isWechatBinding = [[data objectForKey:@"bind_weixin"] boolValue];
                accountManager.f_eliminate = [data objectForKey:@"eliminate"];
                
                success_(message,@"成功");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}

/**
 *  检查手机号
 *
 *  @param phoneNum_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)checkMobile:(NSString *)phoneNum_
                              success:(void (^)(id responseObject,NSString *message))success_
                              failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_check_mobile;
    
    NSDictionary *dic = @{@"mobile": phoneNum_};
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            if (code == 200) {
                success_(message,@"成功");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}


/**
 *  发送验证码
 *
 *  @param phoneNum_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)sendForgotCode:(NSString *)phoneNum_
                                 success:(void (^)(id responseObject,NSString *message))success_
                                 failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_forgot_code;
    
    NSDictionary *dic = @{@"phone_num": phoneNum_,@"typecode":@"1"};
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            if (code == 200) {
                success_(@"验证码已成功发送到您的手机上",@"验证码已成功发送到您的手机上");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
    
}

/**
 *  修改密码
 *
 *  @param userid_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doEditUserPassword:(NSString *)phoneNum_
                                    password:(NSString *)password_
                                    code:(NSString *)code_
                                     success:(void (^)(id responseObject,NSString *message))success_
                                     failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_modify_password;
    
    NSDictionary *dic = @{@"mobile": phoneNum_,@"password":password_,@"code":code_};
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            if (code == 200) {
                success_(message,@"成功");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
    
}



/**
 *  修改用户信息
 *
 *  @param userid_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doEditUserInfo:(NSString *)userid_
                                nickname:(NSString *)nickname_
//                               phoneNum:(NSString *)phoneNum_
                                success:(void (^)(id responseObject,NSString *message))success_
                                failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_edit_user;
    
    NSDictionary *dic = @{@"userid": userid_,
                          @"nickname": nickname_};
    
    
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            
            if (code == 200) {
                [AccountManager sharedAccountManager].f_nickname = [[responseObject objectForKey:@"data"] objectForKey:@"nickname"];
                success_(message,@"成功");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}

/**
 *  修改绑定手机号
 *
 *  @param userid_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doThirdPartBindingPhone:(NSString *)userid_
                                         phoneNum:(NSString *)phoneNum_
                                             code:(NSString *)code_
                                         password:(NSString *)pwd_
                                          success:(void (^)(id responseObject,NSString *message))success_
                                          failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_thirdpart_binding;
    
    NSDictionary *dic = @{@"userid": userid_,
                          @"phone_num": phoneNum_,
                          @"password":pwd_,
                          @"code": code_};
    
    
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            
            if (code == 200) {
                NSDictionary *data =[responseObject objectForKey:@"data"];
                AccountManager *accountManager = [AccountManager sharedAccountManager];
                accountManager.f_phone_num = [data objectForKey:@"phone_num"];

                success_(message,@"修改成功");
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}

/**
 *  修改用户头像
 *
 *  @param userid_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doEditUserIcon:(NSString *)userid_
                                img_file:(NSString *)img_file_
                                 success:(void (^)(id responseObject,NSString *message))success_
                                 failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_edit_usericon;
    
    NSDictionary *dic = @{@"userid": userid_
                          };
    
    NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer]
                                    multipartFormRequestWithMethod:@"POST"
                                    URLString:urlString
                                    parameters:dic
                                    constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
                                        
                                        [formData appendPartWithFileURL:[NSURL fileURLWithPath:img_file_] name:@"img_file" fileName:@"test1.png" mimeType:@"image/png" error:nil];
                                        
                                    } error:nil];
    
    
    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    
    AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializer];
    responseSerializer.acceptableContentTypes = [NSSet setWithArray:@[@"text/html",@"application/json"]];
    manager.responseSerializer = responseSerializer;
    
    NSURLSessionUploadTask *task = [manager uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
        if(!error)
        {
            if ([responseObject isKindOfClass:[NSDictionary class]]) {
                NSDictionary *responseDic = (NSDictionary *)responseObject;
                if ([[responseDic objectForKey:@"success"] integerValue] == 200) {
                    [AccountManager sharedAccountManager].f_user_img = [[responseObject objectForKey:@"data"] objectForKey:@"user_img"];
                    success_(nil,@"上传成功");
                }else {
                    failure_(@"上传失败");

            }
            
        }
            else
            {
                if (failure_) {
                    failure_(@"上传失败");
                }
            }
        }
        else {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }
        
    }];
    
    [task resume];
    return task;
}

/**
 *  我的福利
 *
 *  @param userid_
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doGetMyFuLi:(NSString *)userid_
                            pageindex:(NSInteger)pageindex_
                             pagesize:(NSInteger)pagesize_
                              success:(void (^)(id responseObject,NSString *message))success_
                              failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_my_fuli;
    urlString = [urlString stringByAppendingFormat:@"&userid=%@&pageindex=%ld&pagesize=%ld",userid_,pageindex_,pagesize_];
    
    return [[ServiceUtils commonHTTPManager] GET:urlString parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            NSArray *data = [responseObject objectForKey:@"data"];

            if (code == 200) {
                NSError *error;
                NSArray *list = [MTLJSONAdapter modelsOfClass:[M_Fuli class] fromJSONArray:data error:&error];
                if (!list) {
                    list = @[];
                }
                success_(list,message);
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}

/**
 *  输入邀请码领福利
 *
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doInputFuliCode:(NSString *)userid_
                                   recode:(NSString *)recode_
                                  success:(void (^)(id responseObject,NSString *message))success_
                                  failure:(void (^)(NSString *message))failure_
{
    NSString *urlString = url_net_input_fuli_code;
    
    NSDictionary *dic = @{@"userid": userid_,
                          @"recode": recode_,
                          @"uct":[self getAuthCode]
                          };
    
    
    return [[ServiceUtils commonHTTPManager] POST:urlString parameters:dic success:^(NSURLSessionDataTask *task, id responseObject) {
        
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            
            NSInteger code = [[responseObject objectForKey:@"success"] integerValue];
            NSString *message = [responseObject objectForKey:@"msg"];
            
            if (code == 200) {
                success_(nil,message);
            }
            else {
                failure_(message);
            }
            
        }
        else {
            failure_(@"网络不给力");
        }    } failure:^(NSURLSessionDataTask *task, NSError *error) {
            if (failure_) {
                failure_(@"网络不给力");
            }
        }];
}

/**
 *  个人中心封面
 *
 *  @param success_
 *  @param failure_
 *
 *  @return
 */
+ (NSURLSessionDataTask *)doGetUserCenterCover:(void (^)(id responseObject,NSString *message))success_
                                  failure:(void (^)(NSString *message))failure_ {
    NSString *urlString = url_user_center_cover;
    return [[ServiceUtils commonHTTPManager] GET:urlString parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            success_(responseObject,@"");
        }
        else {
            failure_(@"网络不给力");
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure_) {
            failure_(@"网络不给力");
        }
    }];
}

+ (NSURLSessionDataTask *)doGetHomeTopBar:(void (^)(id, NSString *))success_ failure:(void (^)(NSString *))failure_ {
    NSString *urlString = url_home_top_bar;
    return [[ServiceUtils commonHTTPManager] GET:urlString parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        if (responseObject && [responseObject isKindOfClass:[NSDictionary class]]) {
            success_(responseObject,@"");
        }
        else {
            failure_(@"网络不给力");
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure_) {
            failure_(@"网络不给力");
        }
    }];
}

+ (NSString *)getAuthCode
{
    return [AccountManager sharedAccountManager].f_authCode;
}
@end
